<template>
  <div :id="'app'" :class="isAuthPage ? 'login-bg' : ''" style="height:100vh; width:100vw; overflow:hidden;">
    <template v-if="isAuthPage">
      <router-view />
    </template>
    <template v-else>
      <HeaderBar @logout="handleLogout" />
      <main class="flex-grow-1" style="background:#181A20; height:calc(100vh - 56px); width:100%; overflow:auto;">
        <router-view />
      </main>
    </template>
  </div>
</template>

<script setup>
import { useRouter, useRoute } from 'vue-router';
import { computed } from 'vue';
import HeaderBar from './components/HeaderBar.vue';
const router = useRouter();
const route = useRoute();
const handleLogout = () => {
  router.push('/login');
};
// 判断是否为登录/注册页
const isAuthPage = computed(() =>
  route.path === '/login' || route.path === '/register'
);
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #fff; /* Default text color */
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  background: #181A20;
}

#app.login-bg {
  background-image: url('~@/assets/login-bg.jpg') !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
}

.dashboard-root {
  width: 100%;
  height: 100%;
  background: #181A20;
  padding: 0;
  margin: 0;
}

.row, .col-12, .card, .card-header, .card-body {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.login-bg {
  min-height: 100vh;
  min-width: 100vw;
  background-image: url('@/assets/login-bg.jpg') !important;
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed;
  background-size: cover;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-form {
  background: transparent !important;
  padding: 40px 32px;
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.login-form * {
  background: transparent !important;
}

.login-container {
  background: transparent !important;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 20px;
}

.login-bg > * {
  background: transparent !important;
  box-shadow: none !important;
}
.login-bg .el-row,
.login-bg .el-col,
.login-bg .container,
.login-bg .row,
.login-bg .login-container {
  background: transparent !important;
  box-shadow: none !important;
}

.login-bg .card {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

body {
  background-color: transparent !important; /* Ensure body background is transparent */
}
</style>